package com.longshihan.carservice.service.notice;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.longshihan.carservice.dao.NoticeDao;
import com.longshihan.carservice.model.NoticeDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeDao noticeDao;
    @Override
    public int addNotice(NoticeDomain domain) {
        return noticeDao.addNotice(domain);
    }

    @Override
    public int delNotice(String id) {
        return noticeDao.delNotice(id);
    }

    @Override
    public NoticeDomain getNoticeById(String id) {
        return noticeDao.getNoticeById(id);
    }

    @Override
    public PageInfo<NoticeDomain> getNotices(String userId, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<NoticeDomain> noticeDomains = noticeDao.getNotices(userId);
        PageInfo<NoticeDomain> pageInfo = new PageInfo<>(noticeDomains);
        return pageInfo;
    }
}
